<!--
 * @Author: zhangfan
 * @Date: 2024-06-25 18:36:08
 * @LastEditors: ***
 * @LastEditTime: 2024-06-25 18:38:23
 * @Description: 11
 * @FilePath: /demo/src/views/root/components/child-two.vue
-->
<template>
  <div class="view-contain-two">
    <p>我是子组件2</p>
    <p>{{ child2Data }}</p>
  </div>
</template>
<script>
export default {
  data () {
    return {
      child2Data: 123
    }
  },
  methods: {},
  created () {
    this.$root.$on('changeChild2Data', data => {
      this.child2Data = data // 更新组件数据
    })
  }
}
</script>
<style scoped>
.view-contain-two {
  height: 300px;
  width: 500px;
  border: 1px solid #ccc;
}
</style>
